package com.core.reach.cloudhub.controller;

import com.core.reach.cloudhub.domain.CommonResult;
import com.core.reach.cloudhub.domain.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ga.zhang
 * @version V1.0
 * @description: TODO
 * @date 2020/3/31 14:01
 **/
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    private static Map<Long, Payment> map = new HashMap<>();

    static {
        map.put(1L, new Payment(1L, "serial----------->01"));
        map.put(2L, new Payment(2L, "serial----------->02"));
        map.put(3L, new Payment(3L, "serial----------->03"));
    }

    @GetMapping("/paymentSql/{id}")
    public CommonResult<Payment> paymentSql(@PathVariable("id") Long id) {
        Payment payment = map.get(id);
        return new CommonResult<>(200, "from sql,serverPort:" + serverPort, payment);
    }

}
